// 视频状态常量
export const VideoStatus = {
  COMPLETED: 'completed',
  PROCESSING: 'processing',
  FAILED: 'failed',
  DRAFT: 'draft',
} as const;

export type VideoStatus = (typeof VideoStatus)[keyof typeof VideoStatus];

// 视频类型常量
export const VideoType = {
  GENERATED: 'GENERATED',
  TRANSLATED: 'TRANSLATED',
} as const;

export type VideoType = (typeof VideoType)[keyof typeof VideoType];

// 视频数据接口（对齐后端 CachedVideo 模型）
export interface Video {
  // BaseModel fields
  id: number;
  created_at_time: string;
  updated_at: string;
  deleted_at?: string | null;

  // 基本字段（来自 /v1/video.list）
  video_id: string;
  status: VideoStatus | string;
  video_title: string;
  created_at: number; // Unix timestamp
  type: VideoType | string;
  folder_id: string;

  // 补充字段（来自 /v1/video_status.get）
  callback_id?: string | null;
  caption_url: string;
  duration: number; // 视频时长（秒）
  error?: Record<string, unknown>; // JSON field for errors
  gif_url: string;
  thumbnail_url: string;
  video_url: string;
  video_url_caption?: string | null;

  // 自定义字段
  account_id: number;
  last_sync_at: string;
  account?: Record<string, unknown>; // HeygenAccount relation
}

// 视频列表响应
export interface VideoListResponse {
  videos: Video[];
  total: number;
  page?: number;
  pageSize?: number;
}

// 视频生成请求（预留）
export interface VideoGenerateRequest {
  avatar_id?: string;
  talking_photo_id?: string;
  voice_id?: string;
  script: string;
  title?: string;
  background?: string;
  aspect_ratio?: '16:9' | '9:16' | '1:1';
  folder_id?: string; // 输出文件夹ID
}

// 视频生成响应（预留）
export interface VideoGenerateResponse {
  video_id: string;
  status: VideoStatus;
  message?: string;
}

// 视频同步结果
export interface VideoSyncResult {
  account_id: number;
  account_name: string;
  videos_synced: number;
  errors?: string[];
  start_time: string;
  end_time: string;
  duration: string;
}
